package twu;

/**
 * Created by twer on 7/9/14.
 */
public class FizzBuzz {

    public String getElement(int num) {
        boolean isDivisibleByThree = isDivisible(3,num);
        boolean isDivisibleByFive = isDivisible(5,num);

        if( isDivisibleByThree) {
            if (isDivisibleByFive)
                return "FizzBuzz";
            else
                return "Fizz";
        }
        else {
            if (isDivisibleByFive)
                return "Buzz";
            else
                return String.valueOf(num);
        }
    }

    private boolean isDivisible(int divisor,int dividend){
        int remainder = dividend % divisor;
        if( remainder == 0)
            return true;
        else
            return false;
    }

    public String run(int size) {
        String output = "";
        for (int i = 1; i<=size ; i++){
            output += getElement(i);
            output += "\n";
        }
        return output;
    }
}
